package com.lpx.demo.demo.service.impl.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lpx.demo.demo.entity.BaseUserEntity;
import com.lpx.demo.demo.service.base.BaseUserService;
import com.lpx.demo.demo.service.impl.BaseServiceimpl;
import com.lpx.demo.demo.util.Md5utils;
import com.lpx.demo.demo.util.UUIDUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class BaseUserSerivceimpl extends BaseServiceimpl<BaseUserEntity> implements BaseUserService {
    @Override
    public boolean registered(BaseUserEntity entity) {
        String salt = UUIDUtils.getSalt();
        entity.setCreateTime(new Date());
        entity.setPassword(Md5utils.passwordToMd5(entity.getPassword(), salt));
        entity.setSalt(salt);
        if(this.insert(entity)>0){
            return true;
        }
        return false;
    }
}
